﻿@using OJS.Common.Models
@model OJS.Web.Areas.Contests.ViewModels.Contests.QuestionViewModel

@using Resource = Resources.Areas.Contests.Views.CompeteRegister;

<div class="form-group">
    @Html.HiddenFor(x => x.QuestionId)
    <div class="editor-label">
        @Html.Label(Model.Question, Html.ValueFor(x => x.Question))
    </div>
    <div class="editor-field">
        @{
            var htmlAttributes = new
            {
                @class = "form-control",
                data_val_regex_pattern = !string.IsNullOrWhiteSpace(Model.RegularExpression) ? Model.RegularExpression : ".*",
                data_val_regex = "Invalid answer format"
            };
        }

        @switch (Model.Type)
        {
            case ContestQuestionType.Default:
                @Html.TextBoxFor(x => x.Answer, htmlAttributes)
                break;
            case ContestQuestionType.DropDown:
            @Html.DropDownListFor(x => x.Answer, Model.DropDownItems, @Resource.Select_dropdown_answer, new { @class = "form-control" })
                break;
            case ContestQuestionType.TextBox:
            @Html.TextBoxFor(x => x.Answer, htmlAttributes)
                break;
            case ContestQuestionType.MultiLineTextBox:
            @Html.TextAreaFor(x => x.Answer, htmlAttributes)
                break;
            default:
            @Html.TextBoxFor(x => x.Answer, htmlAttributes)
                break;
        }
        @Html.ValidationMessageFor(x => x.Answer)
    </div>
</div>